import { ObjCreate } from "../../common/ObjCreate";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { MoneyUtil } from "../../common/util/MoneyUtil";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
type int = number;
//class PriceItem
    
    export  class PriceItem /* flash.display.Sprite */
    {
        constructor(arg1: int=1, arg2: int=100, arg3: Boolean=false)
        {
            
            this._goldNum = arg1;
            this._coinNum = arg2;
            this._isEdit = arg3;
            this.initView();
            this.addConfig();
            return;
        }

        /* internal  */initView(): void
        {
            this._bg = ObjCreate.createBg(0, 0, 130, 20, this);
            this._tfGold = ObjCreate.createTextField(this._goldNum.toString(), 0, 0, 40, 20, this);
            this._tfGold.autoSize = flash.text.TextFieldAutoSize.RIGHT;
            this._tfGold.selectable = true;
            this._tfCoin = ObjCreate.createTextField(this._coinNum.toString(), 60, 0, 50, 20, this);
            this._tfCoin.autoSize = flash.text.TextFieldAutoSize.RIGHT;
            this._tfCoin.selectable = true;
            this._bmpGold = GlobalClass.getBitmap("Yuanbao_small");
            this._bmpGold.x = 40;
            this._bmpGold.y = 1;
            this.addChild(this._bmpGold);
            this._bmpCoin = GlobalClass.getBitmap("Tongqian_small");
            this._bmpCoin.x = 110;
            this._bmpCoin.y = 1;
            this.addChild(this._bmpCoin);
            this.draw();
            return;
        }

        public draw(): void
        {
            this._tfGold.width = this._goldWidth;
            this._tfCoin.width = this._coinWidth;
            this._tfGold.maxChars = this._goldMaxSize;
            this._tfCoin.maxChars = this._coinMaxSize;
            this._tfGold.x = this._goldWidth - 9;
            this._bmpGold.x = this._goldWidth;
            this._tfCoin.x = this._bmpGold.x + this._bmpGold.width + this._coinWidth - 21;
            this._bmpCoin.x = this._bmpGold.x + this._bmpGold.width + this._coinWidth;
            if (this._isShowBg) 
            {
                this._bg.width = this._bmpCoin.x + this._bmpCoin.width;
                this._bg.visible = true;
            }
            else 
            {
                this._bg.visible = false;
            }
            return;
        }

        /* internal  */addConfig(): void
        {
            this._tfGold.maxChars = 5;
            this._tfGold.restrict = "0-9";
            this._tfCoin.maxChars = 7;
            this._tfCoin.restrict = "0-9";
            if (this._isEdit) 
            {
                this._tfGold.type = flash.text.TextFieldType.INPUT;
                this._tfCoin.type = flash.text.TextFieldType.INPUT;
            }
            return;
        }

        public get isEdit(): Boolean
        {
            return this._isEdit;
        }

        public set isEdit(arg1: Boolean)
        {
            this._isEdit = arg1;
            if (this._isEdit) 
            {
                this._tfGold.type = flash.text.TextFieldType.INPUT;
                this._tfCoin.type = flash.text.TextFieldType.INPUT;
            }
            else 
            {
                this._tfGold.type = flash.text.TextFieldType.DYNAMIC;
                this._tfCoin.type = flash.text.TextFieldType.DYNAMIC;
            }
            return;
        }

        public get goldTextField(): Object /* flash.text.TextField */
        {
            return this._tfGold;
        }

        public get coinTextField(): Object /* flash.text.TextField */
        {
            return this._tfCoin;
        }

        public updateCoin(arg1: int): void
        {
            this._tfCoin.htmlText = MoneyUtil.getCoinHtml(arg1);
            return;
        }

        public updateGold(arg1: int): void
        {
            this._tfGold.htmlText = MoneyUtil.getGoldHtml(arg1);
            return;
        }

        public isShowBg(arg1: Boolean): void
        {
            this._isShowBg = arg1;
            this.draw();
            return;
        }

        public set goldMaxSize(arg1: int)
        {
            this._goldMaxSize = arg1;
            return;
        }

        public set coinMaxSize(arg1: int)
        {
            this._coinMaxSize = arg1;
            return;
        }

        public set goldLength(arg1: int)
        {
            this._goldWidth = arg1;
            this.draw();
            return;
        }

        public set coinLength(arg1: int)
        {
            this._coinWidth = arg1;
            this.draw();
            return;
        }

        /* internal */ /* var */_bg: ScaleBitmap;

        /* internal */ /* var */_tfGold: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfCoin: Object /* flash.text.TextField */;

        /* internal */ /* var */_bmpGold: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bmpCoin: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_isEdit: Boolean;

        /* internal */ /* var */_goldNum: int;

        /* internal */ /* var */_coinNum: int;

        /* internal */ /* var */_goldWidth: int=35;

        /* internal */ /* var */_coinWidth: int=47;

        /* internal */ /* var */_goldMaxSize: int=5;

        /* internal */ /* var */_coinMaxSize: int=7;

        /* internal */ /* var */_isShowBg: Boolean=true;
    }
